<template>
  <div v-for="article in data">
    <ArticleListItem :article="article" />
    <Line />
  </div>
  <div v-if="data.length == 0">暂无内容，等待上传中...</div>
</template>
<script setup>
import ArticleListItem from "@/components/ArticleListItem.vue";
import Line from "@/components/Line.vue";
import { getArticleList } from "@/api/article";
import { ref, watch } from "vue";
import Enums from "@/utils/Enums";
import { useUserStore } from "@/stores/userStore";
const userStore = useUserStore();
const props = defineProps({
  userId: {
    type: Number,
    required: false,
  },
  searchTitle: {
    type: String,
    required: false,
  },
  status: {
    type: Number,
    required: false,
  },
});
const data = ref([]);

const params = ref({
  page: 1,
  pageSize: 100,
  searchTitle: "",
});

watch(
  () => userStore.searchKey,
  () => {
    debugger;
    params.value.searchTitle = userStore.searchKey;
    params.page = 1;
    getData();
  }
);
const getData = () => {
  getArticleList({
    ...params.value,
    status: props.status,
    userId: props.userId,
    title: props.searchTitle,
    typeId: userStore.currentType,
  }).then((res) => {
    data.value = res.data.data.records;
  });
};
watch(() => userStore.currentType, getData);
getData();
</script>
